<template>
    <div style="background-color: #f4f4f4">
        <div class="p-user-center" style="min-height:100%;">
            <div class="back-ground"></div>
            <div class="page-body">
                <div class="user-profile">
                    <div class="avatar">
                        <div class="c-face-img-con c-face-img" style="width: 160px; height: 160px;">
                            <img class="personalImg" :src="imgUrl+demandUser.userImg" alt="" title=""
                                 style="border-radius: 50%;">
                        </div>
                    </div>
                    <div class="user-info">
                        <div class="name-row">
                            <span class="name">{{demandUser.username}}</span>
                        </div>
                        <div class="describe">
                            {{demandUser.introduction}}
                        </div>

                    </div>
                    <section class="user-profile__employer-credit">
                        <div class="el-tooltip credit__block-wrapper"
                             aria-describedby="el-tooltip-7528" tabindex="0"><span
                                class="credit__block-name">需求完成率</span>
                            <div class="credit__wrapper"><span
                                    class="credit__block-count is-none"
                                    style="font-family: osp-din;">暂无</span>
                            </div>
                        </div>
                    </section>

                </div>

            </div>
            <div>
                <el-tabs class="tab-header" v-model="activeName" @tab-click="handleClick">
                    <el-tab-pane name="demands" label="Ta的需求" class="el-tabs__item is-top">
                        <PersonalDemands></PersonalDemands>
                    </el-tab-pane>
                    <el-tab-pane name="works" label="Ta的作品" class="el-tabs__item is-top">
                        <HerWorks></HerWorks>
                    </el-tab-pane>

                </el-tabs>
            </div>
        </div>


    </div>

</template>

<script setup>
  import HerWorks from "@/views/userPage/HerWorks.vue";
  import PersonalDemands from "@/views/userPage/PersonalDemands.vue";
  import {selectUser} from "@/assets/api/userApi";
  import {getCurrentInstance, onBeforeMount, ref} from "vue";
  import {useRoute} from "vue-router";

  const imgUrl = getCurrentInstance()?.appContext.config.globalProperties.$imgUrl
  const route = useRoute();

  const demandUser = ref({});
  const activeName = ref("demands");

  const getUserInformation = () => {
    let data = {};
    data.userId = route.query.id;
    selectUser(data).then((res) => {
      demandUser.value = res.data;
    })
  };
  const handleClick = (tab, event) => {

  };

  onBeforeMount(() => {
    getUserInformation();
  });

</script>

<style scoped>
    .p-user-center {
        position: relative;
        padding-top: 70px;
        padding-bottom: 120px;
        background: #f4f4f4;
    }

    .back-ground {
        background-image: url("../../assets/img/personalPageBg.png");
        background-repeat: repeat;
        background-size: 100% 100%;
        position: absolute;
        height: 300px;
        top: 0;
        left: 0;
        right: 0;
        z-index: 0;
    }

    .page-body {
        width: 1200px;
        margin: 0 auto;
        z-index: 1;
        position: relative;
    }

    .user-profile {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        min-height: 160px;
    }

    .personalImg {
        height: 160px;
        width: 160px;
    }

    .avatar {
        height: 160px;
        width: 160px;
    }

    .c-face-img-con {
        display: inline-block;
        position: relative;
    }

    .user-info {
        flex-grow: 1;
        margin-left: 40px;
    }

    .name-row {
        height: 40px;
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-align: center;
        -ms-flex-align: center;
        align-items: center;
    }

    .name {
        font-size: 30px;
        color: #fff;
    }

    .describe {
        height: 28px;
        font-size: 16px;
        color: #aaa;
        line-height: 21px;
        margin-top: 16px;
        word-break: break-all;
    }

    .tab-header {
        background-color: #ffffff;
        height: 100px;
        -webkit-box-align: center;
        -ms-flex-align: center;
        align-items: center;
        margin: 70px auto !important;
        font-size: 26px;
    }

    /deep/ .el-tabs__item{
        width:100%;
    }
    /deep/ .el-tabs__nav{
        white-space: nowrap;
        position: relative;
        transition: transform .3s;
        float: left;
        z-index: 2;
        left: 350px;
        font-size: 38px;
    }

    .user-profile__employer-credit {
        display: flex;
        height: 70px;
    }

    .credit__block-wrapper {
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .credit__block-name {
        font-size: 16px;
        font-weight: 500;
        color: #ffffff;
    }

    .credit__wrapper {
        display: flex;
        align-items: center;
    }

    .credit__block-count {
        color: #9b9b9b;
        font-size: 16px;
        margin-right: 10px;
    }

    .credit__phase-state {
        border: 1px solid silver;
        color: silver;
        font-size: 12px;
        width: 40px;
        line-height: 16px;
        border-radius: 10px;
        text-align: center;
    }
</style>
